<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>A33信息</title>

    <link rel="stylesheet" th:href="@{/static/iview/iview.css}">
    <script th:src="@{/static/libs/jquery-3.2.1.min.js}" type="text/javascript"></script>
	<script th:src="@{/static/libs/vue.min.js}" type="text/javascript"></script>
	<script th:src="@{/static/layer/layer.js}" type="text/javascript"></script>
   <script th:src="@{/static/iview/iview.min.js}" type="text/javascript"></script>
	<script th:src="@{/static/common.js}" type="text/javascript"></script>
    <style type="text/css">
	[v-cloak] {
			  display: none;
			}
	</style>
</head>
<body>
<div id="app" v-cloak>
        <div style="margin-bottom: 6px;margin: 30px">
			<i-input v-model="content" placeholder="查询"  style="width: 300px"></i-input>
			<i-button type="primary" @click="search()" icon="ios-search">搜索</i-button>
			<i-button type="primary" @click="empty()" icon="ios-close-empty">清空</i-button>
		</div>
		<div style="margin-bottom: 6px;margin: 30px">
			<template> 
				<i-table border :content="self" :columns="tableTitle" :data="datalist"></i-table>
			 	<br>
<!-- 			 	<Page :total="dataCount" :page-size="pageSize" show-total @on-change="changepage" @on-page-size-change="changePageSize"></Page> -->
			 	<!--分页功能-->
				<Page :current="1" :total="dataCount" :page-size="pageSize"  @on-change="changepage"  show-elevator show-sizer show-total></Page>
				 
			</template>
		</div>
</div>
<script type="text/javascript">
var vm = new Vue({
	el : '#app',
	data : {
		content : '',
		pageNo : 0,
		pageSize : 10,// 每页显示多少条
		dataCount:"", // 总数据的条目
		datalist: [], //接口获取的总数据
		historyData:'',//展示的数据 
		tableTitle:[ 
		{
		   title : "编号",
		   type: 'index',
		   align: 'center',
            width: 70
		 },
		 {
				key : "id",
				title : "主键标识",
				width : 120
		 },
		{
			key : "dataType",
			title : "类型",
			width : 90
		},	
		{
			key : "fileName",
			title : "业务名称",
			width : 200
		},
		{
			key : "sender",
			title : "编号"
		}, 
		{
			key : "redisTime",
			title : "入Redis时间",
			render : function(h, params) {
				  return h('div',
						  formatDate(new Date(params.row.redisTime),'yyyy-MM-dd hh:mm:ss'));
			}
		}, 
		{
			key : "fileType",
			title : "文件类型"
		}, 
		
		{
			key : "redisCount",
			title : "Redis次数"
		}, 
		{
			key : "createTime",
			title : "创建时间",
			width : 150,
			render : function(h, params) {
				  return h('div',
						  formatDate(new Date(params.row.createTime),'yyyy-MM-dd hh:mm:ss'));
			}
		}, {
			title : '操作',
			key : 'action',
			width : 90,
			align : 'left',
			render : function(h, params) {
				var functionList = [];
				//修改
				var edit = h('Button', {
					props : {
						type : 'primary',
						size : 'small',
						icon : 'edit'
					},
					style : {
						marginRight : '8px'
					},
					on : {
						click : function() {
							vm.edit(params.row);
						}
					}
				}, '修改');
				functionList.push(edit);
		
				// 返回方法集合
				return h('div', functionList);
			}
		} ]	
	},
	methods : {
		//搜索
		search : function(){
			this.loadlist(1);
		},
		empty : function(){
			vm.content = '';
			this.loadlist(1);
		},
		//任务列表(自行实现分页)
		loadlist : function(index) {
			let self=this;   //申明个this对象
			
			var page = {};
			page['pageIndex']= index ;
			page['pageSize']= this.pageSize;
					
			var params = {};
			if(this.content !=''){
				params['id'] = this.content;
				params['businessName'] = this.content;
				params['urlPathPrefix'] = this.content;
				
				 var number = parseInt(this.content);
					if(number != 'undefind'){
						params['dataType'] = number;
					}
			}
			
			 var conditional = {};
			 conditional['page'] = page;
			 conditional['params'] = params;
			 
			var json =  JSON.stringify(conditional);

			
			$.ajax({
				url:"../monitor/getA23DataFile",
				type:"post",
				dataType: "json",
				contentType: 'application/json', 
				data: json,
				success: function(data) {
					vm.datalist = data.result.rows;
					vm.dataCount = data.result.total; //接口返回数据的总条目数
					if(vm.dataCount < vm.pageSize){   
                        vm.historyData   = vm.JobData
                    }else{
                        vm.historyData = vm.datalist.slice(0,self.pageSize);
                    }
				}
			});
		},
		 //页数变化的时候改变每一页的内容
        changepage(index){
			this.loadlist(index);
        },
		edit : function(request){
			dialogOpen({
				title: '修改',
				url: 'monitor/a22UrlMappingEdit.shtml',
				//屏幕小 滚动条显示
				scroll : true,
				width: '500px',
				height: '600px',
				success : function(iframeId){
					
					var params = {};
					params['id'] = request.id;
					 var conditional = {};
					 conditional['params'] = params;
					 
					var json =  JSON.stringify(conditional);

					
					$.ajax({
						url:'../monitor/getA22UrlMappingEdit',
						type:"post",
						data: json,
						dataType: "json",
						contentType: 'application/json', 
						success: function(data) {
								top.frames[iframeId].vm.formProperty = data.result;
						}
					});
				},
				yes : function(iframeId) {
					top.frames[iframeId].vm.acceptClick();
				},
			});
		},
		//移除任务
		remove : function(jobName,jobGroup){
			var that = this;
			top.layer.confirm('确定要移除任务吗？', {btn: ['确定','取消']}, function(){
				$.ajax({
					url:"../job/remove",
					type:"post",
					data:{'time':(new Date()).toString(),"jobName":jobName,'jobGroup':jobGroup},
					success: function(result) {
						if(result.code=="0"){
							top.layer.msg('任务移除成功', {icon: 1});
							window.setTimeout(that.loadlist(),1500); 
						}
					}
				});
			});
		}
	},
	created : function() {
		 this.loadlist();
         this.changepage(0);
	}
})

</script>
</body>
</html>